{% extends "posts/show/layout.html" %}
{% load static %}
{% load posts %}
{% load text_filters %}

{% block post %}
<section class="content">
    <article class="post post-type-post">
        {% block post_header %}
            <header class="post-header">
                <div class="post-info">
                    {% if post.room %}
                        {% include "rooms/widgets/room.html" with room=post.room type="post" %}
                    {% endif %}
                </div>

                <h1 class="post-title">
                    {% if post.prefix %}{{ post.prefix }} {% endif %}{{ post.title | rutypography }}
                </h1>

                <div class="clearfix10"></div>

                <span class="post-publicity-preferences">
                    {% include "posts/widgets/publicity_preferences.html" with post=post %}
                </span>

                <a class="post-data">
                    {% if post.deleted_at %}
                        <div class="post-label">
                            <span class="label label-type-deleted">
                                <span class="label-title">Удалённый пост</span>
                            </span>
                        </div>
                    {% elif post.visibility == "draft" %}
                        <div class="post-label">
                            {% include "posts/widgets/draft_label.html" %}
                        </div>
                    {% endif %}

                    <div class="post-actions-line">
                        {% include "posts/widgets/post_actions_line.html" %}
                    </div>

                    {% if post.metadata.badges %}
                        <a class="post-badges post-badges-center" href="{% url "profile_badges" post.author.slug %}">
                            {% include "badges/widgets/badges.html" with badges=post.metadata.badges %}
                        </a>
                    {% endif %}

                    <div class="post-author">
                        {% include "users/widgets/tiny.html" with user=post.author show_name=True %}

                        {% if post.coauthors %}
                            {% for coauthor in post.coauthors_with_details %}
                                &nbsp;&nbsp;
                                {% include "users/widgets/tiny.html" with user=coauthor show_name=True %}
                            {% endfor %}
                        {% endif %}
                    </div>

                    {% if post.label %}
                        <div class="post-label">
                            {% include "posts/widgets/label.html" with label=post.label %}
                        </div>
                    {% endif %}

                    {% if post.image %}
                        <div class="post-image">
                            <img src="{{ post.image }}" alt="{{ post.title }}">
                        </div>
                    {% endif %}
                </div>
            </header>
        {% endblock %}

        {% if post.text|length > 10000 %}
            <post-toc comments-count={{post.comment_count}}></post-toc>
        {% endif %}

        {% block post_text %}
            <section class="post-text">
                {% block post_upvote %}
                    <post-upvote :initial-upvotes="{{ post.upvotes }}"
                                 :hours-to-retract-vote="{{settings.RETRACT_VOTE_IN_HOURS}}"
                                 upvote-url="{% url "upvote_post" post.slug %}"
                                 retract-vote-url="{% url "retract_post_vote" post.slug %}"
                                 {% if is_voted %}
                                    initial-is-voted
                                    initial-upvote-timestamp={{upvoted_at}}
                                 {% endif %}
                                 {% if not me|can_upvote_post:post or upvote_disabled %}is-disabled{% endif %}>
                    </post-upvote>
                {% endblock %}

                <div class="text-body text-body-type-post e-content">
                    {% render_post post %}
                </div>
            </section>
        {% endblock %}

        {% block post_footer %}
            {% if me and me.is_active_membership and collectible_tag %}
                {% include "posts/widgets/collectible_tag.html" %}
            {% endif %}

            <section class="post-footer p-author">
                {% if request.me or post.author.profile_publicity_level != "private" %}
                    {% include "users/widgets/card.html" with user=post.author %}
                {% endif %}

                {% if post.coauthors %}
                    {% for coauthor in post.coauthors_with_details %}
                        {% include "users/widgets/card.html" with user=coauthor %}
                    {% endfor %}
                {% endif %}
            </section>
        {% endblock %}
    </article>
</section>
{% endblock %}
